/*!
    \file  gd32f4xx_it.c
    \brief this file includes the interrupt handlers for the application
*/

/*
    Copyright (C) 2016 GigaDevice

    2016-10-19, V1.0.0, demo for GD32F4xx
*/

#include "usbh_int.h"
#include "usbh_core.h"
#include "gd32f4xx_it.h"

extern usb_core_handle_struct usb_core_dev;
extern usbh_host_struct usb_host;
extern uint32_t hwp_delay_num;

/*!
    \brief      this function handles Timer2 Handler.
    \param[in]  none
    \param[out] none
    \retval     none
*/
void TIMER4_IRQHandler(void)
{
    if (timer_interrupt_flag_get(TIMER4, TIMER_INT_UP) != RESET)
    {
        timer_interrupt_flag_clear(TIMER4, TIMER_INT_UP);

        if (hwp_delay_num > 0x00)
        {
            hwp_delay_num--;
        }
        else
        {
            timer_disable(TIMER4);
        }
    }
}
#ifdef USE_USBFS
/*!
    \brief      this function handles USBFS global interrupt request.
    \param[in]  none
    \param[out] none
    \retval     none
*/
void USBFS_IRQHandler(void)
{
    usbh_isr(&usb_core_dev);
}
#elif defined(USE_USBHS)
/*!
    \brief      this function handles USBHS global interrupt request.
    \param[in]  none
    \param[out] none
    \retval     none
*/
void USBHS_IRQHandler(void)
{
    usbh_isr(&usb_core_dev);
}
#endif /* USE_USBFS */
